package idcard;
import framework.Factory;
import framework.Product;
import java.util.HashMap;
import java.util.Map;
/**
 * @Author:DarknessShadow
 * @description:继承工厂类，完成IDCard类实例产生的具体生成操作
 * @date 2020/5/11 13:47
 */
public class IDCardFactory extends Factory {

    private Map<String,Integer> owners = new HashMap<>();
    private int index = 0;

    @Override
    protected Product createProduct(String owner) {
        return new IDCard(owner);
    }

    @Override
    protected void registerProduct(Product product) {
        owners.put(((IDCard) product).getOwner(), index);
        ((IDCard) product).setId(index);
        this.index  ++;
    }

    public Map<String, Integer> getOwners() {
        return owners;
    }
}
